package checkers3d.presentation;

import checkers3d.logic.PlayingSurfacePosition;
import java.awt.Point;

/**
 * A visible GUIContainer for wrapping a PlayingSurface2D render resource.
 *
 * @author Ruben Acuna
 */
public class GUIPlayingSurface2D implements IDrawable
{
    /**
    * The position of this component within a GUIContainer or window space.
    */
    private Point position;

    /**
    * The IRenderResource (always a RenderResourcePlayingSurface2D) that defines
    *  how the component looks.
    */
    private IRenderResource resource;

    /**
     * Class constructor that takes a position on the screen, a 2D
     * PlayingSurfacePosition array, and the size of grid tiles within the array.
     *
     * @param position The position of this object relative to its container.
     * @param surface  2D array of PlayingSurfacePosition.
     * @param tileSize Size of the tiles in pixels.
     */
    public GUIPlayingSurface2D(Point position,
                               PlayingSurfacePosition[][] surface,
                               int tileSize)
    {
        setDrawPosition(position);
        setRenderResource(new RenderResourcePlayingSurface2D(surface, tileSize));
    }

    /**
    * Returns the position of the GUIPlayingSurface2D.
    *
    * @return The position of this GUIPlayingSurface2D.
    * @see IDrawable
    */
    public Point getDrawPosition()
    {
        return position;
    }

    /**
    * Sets the current the position of the GUIPlayingSurface2D.
    *
    * @param  position The new position of this GUIPlayingSurface2D.
    * @see IDrawable
    */
    public void setDrawPosition(Point position)
    {
        this.position = position;
    }

    /**
    * Returns the IRenderResource of the GUIPlayingSurface2D.
    *
    * @return The IRenderResource of this GUIPlayingSurface2D.
    * @see IDrawable
    */
    public IRenderResource getRenderResource()
    {
        return resource;
    }

    /**
    * Sets the current the IRenderResource of the GUIPlayingSurface2D.
    *
    * @param  resource The new IRenderResource of this GUIPlayingSurface2D.
    */
    public void setRenderResource(IRenderResource resource)
    {
        this.resource = resource;
    }

    /**
    * Returns a string representation of the GUIPlayingSurface2D which contains
    * information about its position and IRenderResource.
    *
    * @return       A string representation of this GUIPlayingSurface2D.
    */
    @Override
    public String toString()
    {
        return getClass().getName() + " -> "
                                    + position.toString()
                                    + ", " + resource.toString();
    }
}